<?php

namespace app\server;

use support\Response;

class JsonServer
{
    /**
     * @param int $code
     * @param string $message
     * @return void
     */
    public static function success( int $code = 1, string $message  = 'SUCCESS', array $data = []) : Response
    {
        return self::reslut($code , $message , $data , 200);
    }


    private static function reslut(
        int $code ,
        string $message ,
        array $data,
        int $httpCode = 200
    ) : Response
    {
        $result = compact('code' , 'message' , 'data');
        return  new Response($httpCode , [
            'Content-Type' => 'application/json',
        ] , json_encode($result));
    }
}